package com.tyc;

import com.alibaba.fastjson.JSONObject;
import com.tyc.utill.ILock;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;


/**
 * 类描述
 *
 * @author tyc
 * @version 1.0
 * @date 2022-12-02 14:04:01
 */
@SpringBootTest
public class Demo {
    private static AtomicInteger i = new AtomicInteger(0);
    private static Map<Long,String> users = new HashMap<>();
    private static Map<Integer, List> user = new HashMap<>();
    private static Integer num = 10;

    static {
        for (long n = 0; n < 100; n++) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("id",n);
            jsonObject.put("name","用户-"+n);
            users.put(n,jsonObject.toJSONString());
            int a = Integer.valueOf((n%10)+"");
        }
    }
    @Autowired
    private ILock simpleRedisLock;



    @Test
    public void test(){
        HashSet<Object> objects = new HashSet<>();
        objects.add("1");
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        executorService.execute(()->{
            if(simpleRedisLock.tryLock(3)){

            }else {
                i.getAndIncrement();
            }
        });
    }

}
